package com.lucas.servlet.chapter5.service.iml;

import com.lucas.servlet.chapter5.entity.Blog;
import com.lucas.servlet.chapter5.mapper.BlogMapper;
import com.lucas.servlet.chapter5.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceIml implements BlogService {
    @Autowired
    BlogMapper blogMapper;
    @Override
    public List<Blog> findAll(){
        return blogMapper.selectAll();
    }

    //查询分页数据
    @Override
    public List<Blog>findByPage(Integer page, Integer size){
        //计算第page页需要跳过多少行
        Integer offset = (page - 1)*size;
        return blogMapper.selectBlogsByPage(offset, size);
    }

    //查询博客数量
    @Override
    public Integer count(){
        return blogMapper.selectCount();
    }

}
